<template>
  <div class="app-wrapper">
    <div :class="{ 'fixed-header': $store.state.settings.fixed_header }">
      <navbar />
    </div>
    <div class="flex">
      <sidebar :aMenu="adminMenu" style="z-index: 9" v-if="menuState" />
      <app-main v-if="adminMenu.length > 0" />
    </div>
  </div>
</template>
<script>
import Navbar from "./component/navbar";
import Sidebar from "@/layout/components/sidebar/adminNew";
import AppMain from "@/layout/components/appmain/adminNew";

export default {
  components: {
    Navbar,
    Sidebar,
    AppMain
  },
  data() {
    return {
      menuState: !this.$route.query.app_auth_code
    };
  },
  watch: {
    $route(to) {
      if (to.meta?.route) {
        sessionStorage.setItem("clientelePage", to.meta.route);
      }
    }
  },
  computed: {
    adminMenu() {
      const arr = [];
      if (this.$hasPermission("clientele:myClientele:query")) {
        arr.push({
          icon: "",
          name: "我的客户",
          router: "/clientele/myClientele"
        });
      }
      if (this.$hasPermission("clientele:sea:query")) {
        arr.push({
          icon: "",
          name: "客户公海",
          router: "/clientele/sea"
        });
      }
      if (this.$hasPermission("clientele:member:query")) {
        arr.push({
          icon: "",
          name: "成员管理",
          router: "/clientele/member"
        });
      }
      return arr;
    }
  },
  destroyed() {
    sessionStorage.setItem("clientelePage", "");
  }
};
</script>
